package www.yingdi365.com.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import www.yingdi365.com.R;
import www.yingdi365.com.base.ZjbBaseActivity;
import www.yingdi365.com.constant.Constant;

public class BianJiWAActivity extends ZjbBaseActivity implements View.OnClickListener {

    private TextView textViewRight;
    private EditText editWenAn;
    private String wenAn;
    private String text;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bian_ji_wa);
        init();
    }

    @Override
    protected void initSP() {

    }

    @Override
    protected void initIntent() {
        Intent intent = getIntent();
        wenAn = intent.getStringExtra(Constant.INTENT_KEY.WENAN);
        text = intent.getStringExtra(Constant.INTENT_KEY.TEXT);
    }

    @Override
    protected void findID() {
        textViewRight = (TextView) findViewById(R.id.textViewRight);
        editWenAn = (EditText) findViewById(R.id.editWenAn);
    }

    @Override
    protected void initViews() {
        ((TextView) findViewById(R.id.textViewTitle)).setText("编辑文案");
        textViewRight.setText("确定");
        editWenAn.setText(text);
    }

    @Override
    protected void setListeners() {
        textViewRight.setOnClickListener(this);
        findViewById(R.id.imageBack).setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.imageBack:
                finish();
                break;
            case R.id.textViewRight:
                if (TextUtils.isEmpty(editWenAn.getText().toString())) {
                    Toast.makeText(BianJiWAActivity.this, "请输入文案内容", Toast.LENGTH_SHORT).show();
                    return;
                }
                Intent intent = new Intent();
                intent.putExtra(Constant.INTENT_KEY.WENAN, editWenAn.getText().toString());
                switch (wenAn) {
                    case Constant.INTENT_KEY.WENAN00:
                        setResult(Constant.REQUEST_RESULT_CODE.WENAN00, intent);
                        finish();
                    case Constant.INTENT_KEY.WENAN01:
                        setResult(Constant.REQUEST_RESULT_CODE.WENAN01, intent);
                        finish();
                    case Constant.INTENT_KEY.WENAN02:
                        setResult(Constant.REQUEST_RESULT_CODE.WENAN02, intent);
                        finish();
                        break;
                }
                break;
        }
    }
}
